<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>跳转提示</title>
    <style>
        html,body{width: 100%;height: 100%;margin: 0; padding: 0;overflow: hidden;}
        #canvas{width: 100%;height: 100%;font-family: Arial, Helvetica, sans-serif;font-size: 10px;}
    </style>
</head>
<body>
<canvas id="canvas"></canvas>
<script src="__LIB__layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['layer','form'], function () {
        var $ = layui.$,layer = layui.layer, form = layui.form;
        function trim(str){
            return str.replace(/(^\s*)|(\s*$)/g,"");
        }
        var msg = {
            'code':<?php echo($code);?>,
            'msg':'<?php echo(strip_tags($msg));?>',
            'url':'<?php echo($url);?>',
            'wait':<?php echo($wait);?>,
        };
        setTimeout(function(){
            msg.msg = trim(msg.msg);
            var icon = 5;
            if(parseInt(msg.code)==1){
                icon = 6;
            }
            if(parseInt(msg.wait)>0){
                var msg_txt = msg.msg + '<br/><span id=\"wait\">'+ msg.wait + '</span> 秒后跳转';
                layer.msg(msg_txt, {icon:icon,time:msg.wait*1000}, function(){
                    clearInterval(window.interval);
                    location.href = msg.url;
                });
                var wait = document.getElementById('wait');
                window.interval = setInterval(function(){
                    var time = --wait.innerHTML;
                    if(time <= 0) {
                        clearInterval(interval);
                    };
                }, 1000);
            }else{
                layer.msg(msg.msg, {icon:icon,time:-1});
            }       
        
            var c = $("canvas")[0];
            var ctx = c.getContext("2d");
            c.height =$(window).height();
            c.width = $(window).width();
            var chinese = "010101SZOA101010";
            chinese = chinese.split("");

            var font_size = 10;
            var columns = c.width / font_size;
            var drops = [];
            for (var x = 0; x < columns; x++)
                drops[x] = 1;

            function draw() {
                ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
                ctx.fillRect(0, 0, c.width, c.height);

                ctx.fillStyle = "#00d2ff";
                ctx.font = font_size + "px arial";
                for (var i = 0; i < drops.length; i++) {
                    var text = chinese[Math.floor(Math.random() * chinese.length)];
                    ctx.fillText(text, i * font_size, drops[i] * font_size);
                    if (drops[i] * font_size > c.height && Math.random() > 0.975)
                        drops[i] = 0;
                    drops[i]++;
                }
            }
            setInterval(draw, 30);
        },500);        

    });
</script>
</body>
</html>
